package com.young.common.expression.dns;

import org.apache.commons.lang3.math.NumberUtils;

/**
 * @description：
 * @author: yangyahui01
 * @date: 11/29/24 12:42 PM
 */
public enum  DnsResolverTransmittableEnum {
    DEFAULT(0, "只透传header和parameter中指定的路由规则"),
    ALL(1, "本地文件、header或parameter都会透传"),
    NONE(-1, "任何小于0的值，表示都不透传");

    public final int code;
    public final String meaning;

    private DnsResolverTransmittableEnum(int code, String meaning) {
        this.code = code;
        this.meaning = meaning;
    }

    public static DnsResolverTransmittableEnum codeOf(int code) {
        DnsResolverTransmittableEnum[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            DnsResolverTransmittableEnum e = var1[var3];
            if (e.code == code) {
                return e;
            }
        }

        return null;
    }

    public static DnsResolverTransmittableEnum parse(String source) {
        if (!NumberUtils.isCreatable(source)) {
            return DEFAULT;
        } else {
            int code = NumberUtils.createInteger(source);
            if (code <= NONE.code) {
                return NONE;
            } else {
                return code >= ALL.code ? ALL : DEFAULT;
            }
        }
    }
}
